package cn.isjinhao.ld.provider;

import java.io.IOException;

import cn.isjinhao.ld.common.GreetingService;
import cn.isjinhao.ld.common.PoJo;
import cn.isjinhao.ld.common.Result;
import org.apache.dubbo.common.json.JSON;
import org.apache.dubbo.rpc.RpcContext;

public class GreetingServiceImpl implements GreetingService {

    @Override
    public String sayHello(String name) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "Hello " + name + " " + RpcContext.getContext().getAttachment("company");
    }

    @Override
    public Result<String> testGeneric(PoJo poJo) {
        Result<String> result = new Result<String>();
        result.setSuccess(true);
        try {
            result.setData(JSON.json(poJo));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }

}    